<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台管理</title>
	<!-- <link rel="stylesheet" href="/css/bootstrap.min.css"> -->
	<link rel="stylesheet" href="/public/css/inital.css">
	<link rel="stylesheet" href="/public/css/admin.css">
  	<link href="http://cdn.bootcss.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
  <!-- // <script src="http://cdn.bootcss.com/jquery/2.2.1/jquery.min.js"></script> -->

  	<script src="/public/js/ajax.js"></script>
  	<script src="/public/js/jq.js"></script>
<!-- 编辑器 -->
<script type="text/javascript" src="/public/xheditor/xheditor-1.2.2.min.js"></script>
<script type="text/javascript" src="/public/xheditor/xheditor_lang/zh-cn.js"></script>
 <style>
header h1{
	margin-left: 10px;
	font: bold 30px/80px '微软雅黑';
}

 </style>
</head>
<body>
	<script>
	

		/*控制模块的显示*/ 
   		function show(id,num){
   			//控制颜色显示
   			$('li').prop('id','');
   			var l = $('li')[num].id = 'lihover';
   			//控制右侧模块显示
   			$('article>div').css('display','none');
   			$('#'+id).css('display','block');
   		}
	</script>
<header>
<h1 style="float:left">后台管理</h1><span>欢迎登录：<?php echo (cookie('user')); ?>&nbsp&nbsp&nbsp<a href="javascript:void(0)" onclick="exit()">退出登录</a></span>

<script>
	
	function exit(){
		var url ='/index.php/home/user/userexit';
		ajax('get',url,null,false);
		location.assign('/index.php');
	}

</script>

</header>
<div class="main">
	<nav>
	   <ul>
	   	<li onclick="show('addart',0)" id="lihover">
	   		<i class="fa fa-tags"></i>文章发布
	   	</li>
	   	<li onclick="show('art',1)" >
	   	    <i class="fa fa-edit"></i>文章列表
	   	</li>
	   	<li onclick="show('addresource',2)">
	   	    <i class="fa fa-navicon"></i>资源发布
	   	</li>
	   	<li onclick="show('resource',3)">
	   	    <i class="fa fa-photo"></i>资源列表
	   	</li>
	   	<li onclick="show('user',4)">
	   	   <i class="fa fa-music"></i></i>会员管理
	   	</li>
	   </ul>	
	</nav>
	<article>	    

	<!-- 以下为发布文章 -->		
		<div id="addart">
		  <form id="addcontent" action="/index.php/admin/index/addart" method="post" >

		  <div style="margin:0 auto;overflow:hidden;width:90%;">
		  
		   <h2 style="margin:0 auto;">文章发布</h2>
		   名称：<br><input type="text" name="title"><br>
		   配图：<br><input type="text" name="img" ><br>
		   年份：<br><input type="text" name="year"><br>
		   	栏目：<select name="class" >	 
		   <?php if(is_array($catall)): foreach($catall as $key=>$v): ?><option value="<?php echo ($v["cat_id"]); ?>">
				<?php echo str_repeat('|-', $v['fj']); ?>
		         <?php echo ($v["catname"]); ?></option><?php endforeach; endif; ?>
		   </select>
		   播放时间：<select name="play_time" id="">
		   		<option value="0">非连载可忽略</option>
		   		<option value="1">周一</option>
		   		<option value="2">周二</option>
		   		<option value="3">周三</option>
		   		<option value="4">周四</option>
		   		<option value="5">周五</option>
		   		<option value="6">周六</option>
		   		<option value="7">周日</option>
		   </select>
		   地区：<select name="region" >
		   			<option value="大陆">大陆</option>
		   			<option value="香港">香港</option>
		   			<option value="台湾">台湾</option>
		   			<option value="日本">日本</option>
		   			<option value="韩国">韩国</option>
		   			<option value="欧美">欧美</option>
		   			<option value="其它">其它</option>
		   		 </select><br>


		   类型：<br><input type="text" name="type"><br>
		   演员：<br><input type="text" name="actor" placeholder='使用空格分隔'><br>
		   
		  
		   介绍：<br><textarea id="content" name="brief" class="xheditor {tools:'Fontface,FontSize,Bold,Italic,Under,FontColorline,BackColor,Removeformat,Align,Link,Unlink,Anchor,Img,Flash,Hr,Emot,Fullscreen,Source',skin:'nostyle'}" name="content" style="width: 100%;height:400px;" autofocus ></textarea> <br>
		   度盘地址：<br><input type="text" name="baidu"><br>
		   度盘密码：<br><input type="text" name="baidu_pwd"><br>
		   <input type="button" class="submit" value="提交" onclick="addart()" >

		   </div>

		  </form>
		</div>

	<!-- 以下为读取文章列表 -->
		<div id="art" style="display:none">
			<h2>文章列表</h2>
		  	<table  class="table" id="selectart">	
		  		 </table>
		</div>
		

		<script>
			//ajax文章添加
			function addart(){
				var url = '/index.php/admin/index/addArt';
				var content = $('#content').val();
				var em = $('#addcontent')[0];
				var data = new FormData(em);
				var rsu = ajax('formdata',url,data,false,false);
				alert(rsu);
				if (rsu == '添加成功') {										
					$('#addcontent input:text').val('');
					$('#addcontent textarea').val('');
					artall();
				};	 
			}
			//取出文章
			function getart(){
				var url = '/index.php/admin/index/getArt';
				var data = ajax('get',url,null,false,false);
				var data = eval(data);
				var inner = '';
				for (var i = 0; i < data.length; i++) {
					inner += '<tr><td>'+data[i]['art_id']+'</td>';
	         		inner += '<td>'+data[i]['title']+'</td>';
	         		inner += '<td>'+data[i]['year']+'</td>';
	         		inner += '<td>'+data[i]['type']+'</td>';
	         		inner += '<td>'+data[i]['catname']+'</td>';
	         		inner += '<td>'+data[i]['region']+'</td>';
	         		if (data[i]['status'] == 1) {
	         			var status = '完结';
	         		}else{
	         			var status = '连载';
	         		};
	         		inner += '<td>'+status+'</td>';
	         		inner += '<td>'+getdate(data[i]['update_time']*1000)+'</td>';
	         		inner += '<td><a href="/index.php/sp/id/'+data[i]['art_id']+'" target="_blank" >查看</a>&nbsp&nbsp&nbsp';
	         		inner += '<span onclick=delart('+data[i]['art_id']+')>删除</td></tr>';
				};
				return inner;
			}
			function artall(){
				var inner = getart();
				$('#selectart').html('<tr> <th>序号</th> <th>标题</th> <th>年份</th> <th>类型</th> <th>栏目</th> <th>地区</th> <th>状态</th> <th>更新时间</th> <th>操作</th> </tr>'+inner);
			}
			artall();
		</script>


		<!-- 以下为资源发布 -->		
		<div id="addresource" style="display:none">

		  <form id="addrso" >

		  	<div style="margin:0 auto;overflow:hidden;width:90%;">
		  
			   <h2 style="margin:0 auto;">资源发布</h2>
			   文章id：<br><input type="text" name="art_id"><br>
			   第几集：<br><input type="text" name="num"><br>
			   状态：<select name="status" >
			   			<option value="0">连载</option>
			   			<option value="1">完结</option>
			   		 </select><br>
			   迅雷地址：<br><input type="text" name="thunder"><br>
			   <input type="button" class="submit" value="提交" onclick="addrso()" >
		   </div>

		  </form>
		</div>


		<!-- 以下为读取资源列表 -->
		<div id="resource" style="display:none">
			<h2>资源列表</h2>
		  	<table  class="table" id="selectresource">	
		  		 </table>
		</div>

		<script>
			// 资源添加
			function addrso(){
				var url = '/index.php/admin/index/addResource';
				var em = $('#addrso')[0];
				var data = new FormData(em);
				var rsu = ajax('formdata',url,data,false,false);
				alert(rsu);
				if (rsu == '添加成功') {										
					$('#addrso input[name=thunder]').val('');
					rsoall();
				};	 
			}
			//资源取出
			function getrso(){
				var url = '/index.php/admin/index/getResource';
				var data = ajax('get',url,null,false,false);
				var data = eval(data);
				var inner = '';
				for (var i = 0; i < data.length; i++) {
					inner += '<tr><td>'+data[i]['r_id']+'</td>';
	         		inner += '<td><a href="/index.php/sp/id/'+data[i]['art_id']+'" target="_blank" >'+data[i]['title']+'</a></td>';
	         		inner += '<td>'+data[i]['num']+'</td>';
	         		if (data[i]['status'] == 1) {
	         			var status = '完结';
	         		}else{
	         			var status = '连载';
	         		};      	
	         		inner += '<td>'+status+'</td>';
	         		inner += '<td>'+getdate(data[i]['pubtime']*1000)+'</td>';	
	         		inner += '<td><span onclick=delrso('+data[i]['r_id']+')>删除</td></tr>';
				};
				
				return inner;
			}
			getrso();
			function rsoall(){
				var inner = getrso();
				$('#selectresource').html('<tr> <th>序号</th> <th>文章</th> <th>第几集</th> <th>状态</th> <th>更新时间</th> <th>操作</th> </tr>'+inner);
			}
			rsoall();

		</script>


	</article>

</div>




<footer> 版权所有，保留一切权利 !  © 2016</footer>
	
</body>
</html>